//
//  ViewController.m
//  王宇先_14_自定义Cell侧滑删除_StoryBoard 应用
//
//  Created by wyx on 16/3/28.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "ViewController.h"
#import "TableViewOfContact.h"
#import "TableViewCellOfContact.h"

static NSString *pool1 = @"pool1";
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource,TableViewCellOfContactDelegate>
@property(nonatomic, retain) TableViewOfContact *tableViewOfContact;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTableView];
    // Do any additional setup after loading the view, typically from a nib.
}
#pragma mark - 创建 tableView
-(void)createTableView {
    self.tableViewOfContact = [[TableViewOfContact alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableViewOfContact.delegate = self;
    self.tableViewOfContact.dataSource = self;
    self.tableViewOfContact.separatorColor = [UIColor redColor];
    [self.tableViewOfContact registerClass:[TableViewCellOfContact class] forCellReuseIdentifier:pool1];
    [self.view addSubview:self.tableViewOfContact];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 20;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TableViewCellOfContact *cell = [tableView dequeueReusableCellWithIdentifier:pool1];
    cell.delegate1 = self;
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
    
}
- (void)scrollButtonDidTouched:(TableViewCellOfContact *)tableViewCell {
    NSIndexPath *indexpath = [self.tableViewOfContact indexPathForCell:tableViewCell];
    [self.tableViewOfContact deleteRowsAtIndexPaths:@[indexpath] withRowAnimation:UITableViewRowAnimationAutomatic];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
